<%@Page Language="VB" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- #include file="style.inc" -->
</head>
<body>
<!--------------------------------------------------------------------------->
<span class="heading">The ASP Web Forms Command Events</span><p />

<form runat="server">

<table border="0">
<tr>

<td align="right">CommandName:</td>
<td><input id="b1cname" type="text" value="Command1" runat="server" />
<input type="submit" value="Update" /></td>
<td rowspan="2" align="center"> &nbsp; &nbsp;
  <asp:Button id="MyButton" OnCommand="MyCommandCode"
       Text="Run Command" runat="server"
       ToolTip="This is a Button control" />
</td>
</tr><tr>
<td>CommandArgument:</td>
<td><input id="b1cargs" type="text" value="Action1" runat="server" />
<input type="submit" value="Update" /></td>

</tr><tr><td colspan="3"><hr /></td></tr><tr>

<td align="right">CommandName:</td> &nbsp; &nbsp;
<td><input id="b2cname" type="text" value="Command2" runat="server" />
<input type="submit" value="Update" /></td>
<td rowspan="2" align="center"> &nbsp; &nbsp;
  <asp:ImageButton id="MyImageButton" OnCommand="MyCommandCode"
       ImageUrl="ClickmeButton.gif" runat="server" ImageAlign="absbottom"
       ToolTip="This is an ImageButton control" />
</td>
</tr><tr>
<td>CommandArgument:</td>
<td><input id="b2cargs" type="text" value="Action2" runat="server" />
<input type="submit" value="Update" /></td>

</tr><tr><td colspan="3"><hr /></td></tr><tr>

<td align="right">CommandName:</td>
<td><input id="b3cname" type="text" value="Command3" runat="server" />
<input type="submit" value="Update" /></td>
<td rowspan="2" align="center"> &nbsp; &nbsp;
  <asp:LinkButton id="MyLinkButton" OnCommand="MyCommandCode"
       Text="Run Command" runat="server"
       ToolTip="This is a LinkButton control" />
</td>
</tr><tr>
<td>CommandArgument:</td>
<td><input id="b3cargs" type="text" value="Action3" runat="server" />
<input type="submit" value="Update" /></td>
</table>
</form>

<div id="divResult" runat="server" EnableViewState="False" />

<script runat="server">

Sub Page_Load()
  MyButton.CommandName = b1cname.Value
  MyButton.CommandArgument = b1cargs.Value
  MyImageButton.CommandName = b2cname.Value
  MyImageButton.CommandArgument = b2cargs.Value
  MyLinkButton.CommandName = b3cname.Value
  MyLinkButton.CommandArgument = b3cargs.Value
End Sub

Sub MyCommandCode(objSender As Object, objArgs As CommandEventArgs)
  divResult.InnerHtml += "Command event detected for control '" _
                      & objSender.ID & "'<br />" _
                      & "CommandName is '" _
                      & objSender.CommandName _
                      & "', CommandArgument is '" _
                      & objSender.CommandArgument & "'"
End Sub

</script>

<!--------------------------------------------------------------------------->
<!-- #include file="foot.inc" -->
</body>
</html>

